<?php
  class document extends template{
           private $db;
           private $info;
           function document($db,$info='')
          {

            $this->db=$db;
             $this->info=$info;
             //$this->set_folder("infostant");
           
          }
           function gettitledataall()
          {
                $sql="SELECT
               info_title.title,
               info_title.tid,
               info_doc.docid,
               info_doc.title as titledoc,
               info_doc.path
                FROM
                info_title
                INNER JOIN info_doc ON info_title.tid = info_doc.tid";
                $this->db->get_connect();
                $arraydata=$this->db->db_set_recordset($sql);
         
                $arraynewdata=array();
                if(count($arraydata))
                {
                  $temptitle="";
                  $k=0;
                  foreach($arraydata as $valuedata)
                  {
                     if($valuedata['title']!=$temptitle)
                     {
                       $temptitle=$valuedata['title'];
                       
                     
                     }
                     $arraynewdata[$temptitle][$k]['titledoc']=$valuedata['titledoc'];
                     $arraynewdata[$temptitle][$k]['docid']=$valuedata['docid'];
                     $arraynewdata[$temptitle][$k]['path']=$valuedata['path'];
                     $k++;
                  
                  
                  }
                
                }

                $this->db->closedb();
                return $arraynewdata;
      
               }
           function getallshelf()
           {
           $sql="SELECT
                tb_shelf.*
                FROM
                tb_shelf
                ";
           $this->db->get_connect();
           $arraydata=$this->db->db_set_recordset($sql);
           $this->db->closedb();
           return $arraydata;
           
           }
           function view(){ 
           
          $databird['linktosetto']=baseinfo.'/document';
          $databird['data']=$this->gettitledataall();
          $databird['shelf']=$this->getallshelf();
          $this->setdata($databird);
          $this->load('document'); 
        
           
           
           }
        
        
        }
?>
